//===============================================================================
// Microsoft patterns & practices Enterprise Library Contribution
// Query Application Block
//===============================================================================

using System.Collections.Generic;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel;
using EntLibContrib.Query.Parameters;

namespace EntLibContrib.Query.Configuration
{
    using Microsoft.Practices.EnterpriseLibrary.Common.Configuration.Design;

    /// <summary>
	/// Configuration data defining NameValueParameterData.
	/// </summary>    
    [ResourceDescription(typeof(DesignResources), "NameValueParameterDataDescription")]
    [ResourceDisplayName(typeof(DesignResources), "NameValueParameterDataDisplayName")]
	public class NameValueParameterData : ParameterData
	{
		/// <summary>
		/// Initializes a new instance of the <see cref="NameValueParameterData"/> class.
		/// </summary>
		public NameValueParameterData()
            : this(null)
		{
		}

		/// <summary>
		/// Initializes a new instance of the <see cref="NameValueParameterData"/> class.
		/// </summary>
		/// <param name="name">The parameter name.</param>
		public NameValueParameterData(string name)
			: base(name, typeof(NameValueParameter))
		{
		}

		/// <summary>
		/// A <see cref="TypeRegistration"/> container configuration model for <see cref="NameValueParameterData"/>.
		/// </summary>
        /// <param name="name">The name to use for the child elements.</param>
        /// <returns>A <see cref="TypeRegistration"/> for registering a <see cref="NameValueParameterData"/> in the container.</returns>
		public override IEnumerable<TypeRegistration> GetRegistrations(string name)
		{
			yield return
				new TypeRegistration<IParameter>(
					() => new NameValueParameter(Name))
				{
                    Lifetime = TypeRegistrationLifetime.Transient,
					Name = name,
                    IsPublicName = false
				};
		}
	}
}
